import 'package:flutter/material.dart';

import '../l10n/app_localizations.dart';

class IntlExps extends StatelessWidget {
  const IntlExps({super.key});

  @override
  Widget build(BuildContext context) {
    Locale currentLocale = Localizations.localeOf(context);

    return Scaffold(
      appBar: AppBar(title: Text(AppLocalizations.of(context)!.helloWorld)),
      body: Center(
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              /// placeholder
              Text(AppLocalizations.of(context)!.hello('Chase')),

              /// plural
              Text(AppLocalizations.of(context)!.nWombats(0)),
              Text(AppLocalizations.of(context)!.nWombats(1)),
              Text(AppLocalizations.of(context)!.nWombats(5)),

              /// select
              Text(AppLocalizations.of(context)!.pronoun('male')),
              Text(AppLocalizations.of(context)!.pronoun('female')),
              Text(AppLocalizations.of(context)!.pronoun('other')),

              /// escape
              Text(AppLocalizations.of(context)!.helloEscape),

              /// number formatting
              Text(AppLocalizations.of(context)!.numberOfDataPoints(1200000)),

              /// date formatting
              Text(AppLocalizations.of(context)!.helloWorldOn(DateTime.now())),

              /// 部分组件使用其他语言（非选中的语言）
              Localizations.override(
                context: context,
                locale: const Locale('es'),
                child: Builder(
                  builder: (context) {
                    return CalendarDatePicker(
                      initialDate: DateTime.now(),
                      firstDate: DateTime(1900),
                      lastDate: DateTime(2100),
                      onDateChanged: (value) {},
                    );
                  },
                ),
              ),

              /// 显示当前语言
              Text(
                'Current Locale: ${currentLocale.languageCode}'
              ),
            ],
          ),
        ),
      ),
    );
  }
}
